﻿using IT_RoadBlock.Comands;
using IT_RoadBlock.Dto;
using IT_RoadBlock.Handlers;
using HandyControl.Interactivity;
using System;
using System.Windows.Controls;
using System.Windows.Input;

namespace IT_RoadBlock.Controls
{
    /// <summary>
    /// TextDialog.xaml 的交互逻辑
    /// </summary>
    public partial class TextDialog : Border
    {
        private IWindowClose windowClose;
        private Result rs;
        public TextMsg TextMsg { get; set; }

        public TextDialog(IWindowClose _windowClose, Result _rs)
        {
            InitializeComponent();
            this.rs = _rs;
            this.windowClose = _windowClose;
            this.TextMsg = new TextMsg { Info = rs.Message, Title = rs.StatusEnum == StatusEnum.Success ? "提示" : "警告" };
            this.DataContext = this;
        }


        public ICommand CloseCommand
        {
            get => new RelayCommand<object>(CloseCommandAction, CanCloseCommand);
        }

        private bool CanCloseCommand()
        {
            return true;
        }

        private void CloseCommandAction(object obj)
        {
            ControlCommands.Close.Execute(obj, this);
            if(rs.StatusEnum == StatusEnum.Success) windowClose?.CloseWindow?.Invoke();

        }

    }

    public  class TextMsg
    {
        public string Title { get; set; } 
        public string Info { get; set; }
    }

}
